package org.devocean.groupbuying.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

@SuppressWarnings({"serial"})
@Entity
public class User implements Serializable {

	@Id
	@GeneratedValue
	private Integer userID;
	private String username;
	private String password;
	private Boolean enabled;

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "userRole", joinColumns = { @JoinColumn(name = "userID", referencedColumnName = "userID") }, inverseJoinColumns = { @JoinColumn(name = "roleID", referencedColumnName = "roleID") })
	private Set<Role> userRoles = new HashSet<Role>();

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
	private Set<Article> articles;

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
	private Set<Box> boxes;

	public Integer getUserID() {
		return userID;
	}

	public void setUserID(Integer userID) {
		this.userID = userID;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Boolean getEnabled() {
		return enabled;
	}

	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	public Set<Role> getUserRoles() {
		return userRoles;
	}

	public void setUserRoles(Set<Role> userRoles) {
		this.userRoles = userRoles;
	}

	public Set<Article> getArticles() {
		return articles;
	}

	public void setArticles(Set<Article> articles) {
		this.articles = articles;
	}

	public Set<Box> getBoxes() {
		return boxes;
	}

	public void setBoxes(Set<Box> boxes) {
		this.boxes = boxes;
	}

}
